package com.sg.service.biz.component.impl;

import com.sg.common.util.RedisUtil;
import com.sg.dto.base.component.req.QuerySchemeOpenRecordDetailReq;
import com.sg.dto.biz.component.req.*;
import com.sg.dto.biz.component.res.*;
import com.sg.entity.OmsConfApplexRel;
import com.sg.entity.OmsSchemeOpenRecord;
import com.sg.service.base.component.MCustomFields3Service;
import com.sg.service.base.component.MOmsConfApplexRelService;
import com.sg.service.base.component.MOmsSchemeOpenRecordService;
import com.sg.service.biz.component.ConfSchemeService;
import com.sg.common.exception.Assert;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * @author ：
 * @version 1.0
 * @date ：
 */
@Service
public class SecurityServiceImpl
        implements com.wicket.okrcomponent.biz.service.SecurityService {

    @Resource
    private RedisUtil redisUtil;
    @Resource
    private MCustomFields3Service mCustomFields3Service;
    @Resource
    private NbSecurity nbSecurity;
    @Resource
    private ConfSchemeService confSchemeService;
    //@Resource
    //private MOmsSoftwareAuthorizationService mOmsSoftwareAuthorizationService;
    @Resource
    private MOmsSchemeOpenRecordService mOmsSchemeOpenRecordService;
    @Resource
    private MOmsConfApplexRelService mOmsConfApplexRelService;
//@Resource
    //private MMmmShellService mMmmShellService;

    /**
     * D2-3判断云端部署授权可用分析(公共)[6534]
     * gen by moon at 5/9/2023, 5:21:12 AM
     */
    @Trace(operationName = "D2-3判断云端部署授权可用分析(公共)")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public JudgeCloudArrangeEmpowerAvailableComRespDto judgeCloudArrangeEmpowerAvailableCom(JudgeCloudArrangeEmpowerAvailableComReqDto reqDto) {


        ObtainReceiveFieldsRespDto receptionServiceRes_5 = null;
//virtualUsage M2-约定钥匙类型“操作可用”  40657
        //ModelCode: receptionService
        ObtainReceiveFieldsRespDto receptionServiceRes = null;
        ObtainReceiveFieldsReqDto receptionServiceReq = new ObtainReceiveFieldsReqDto();
        receptionServiceReq.setKeyOperateType("OPERATE_USABLE");//sourceId:909127_1_40657

        /*M2-约定钥匙类型“操作可用”[4007]  用于特殊方法接收上游入参。 */
        Assert.isNull(receptionServiceReq.getKeyOperateType(), "D2-3判断云端部署授权可用分析(公共)-M2-约定钥匙类型“操作可用”-钥匙操作类型不能为空", false);
        receptionServiceRes = nbSecurity.obtainReceiveFields(receptionServiceReq);


//virtualUsage M2-约定钥匙类型“操作不可用”  40658
        //ModelCode: receptionService
        ObtainReceiveFieldsRespDto receptionServiceRes_2 = null;
        ObtainReceiveFieldsReqDto receptionServiceReq_1 = new ObtainReceiveFieldsReqDto();
        receptionServiceReq_1.setKeyOperateType("OPERATE_UNUSABLE");//sourceId:909515_1_40658

        /*M2-约定钥匙类型“操作不可用”[4007]  用于特殊方法接收上游入参。 */
        Assert.isNull(receptionServiceReq_1.getKeyOperateType(), "D2-3判断云端部署授权可用分析(公共)-M2-约定钥匙类型“操作不可用”-钥匙操作类型不能为空", false);
        receptionServiceRes_2 = nbSecurity.obtainReceiveFields(receptionServiceReq_1);


        if ((reqDto != null && reqDto.getAuthUseType() != null && reqDto.getAuthUseType().equals("USABLE"))) {
            //if(D2-3判断云端部署授权可用分析(公共).授权使用类型 等于 可用)  40642

//ModelCode: receptionService
            ObtainReceiveFieldsRespDto receptionServiceRes_4 = null;
            ObtainReceiveFieldsReqDto receptionServiceReq_2 = new ObtainReceiveFieldsReqDto();
            if (receptionServiceRes != null) {
                receptionServiceReq_2.setKeyOperateType(receptionServiceRes.getKeyOperateType());//SimpleFieldAssign//sourceId:909319_1_40656
            }

            /*M2-接收钥匙可用类型及授权异常文案[4007]  用于特殊方法接收上游入参。 */
            Assert.isNull(receptionServiceReq_2.getKeyOperateType(), "D2-3判断云端部署授权可用分析(公共)-M2-接收钥匙可用类型及授权异常文案-钥匙操作类型不能为空", false);
            receptionServiceRes_4 = nbSecurity.obtainReceiveFields(receptionServiceReq_2);


            receptionServiceRes_5 = receptionServiceRes_4;
        } else if ((reqDto != null && reqDto.getAuthUseType() != null && reqDto.getAuthUseType().equals("QUANTITY_INS_DISABLED"))) {
            //elseif(D2-3判断云端部署授权可用分析(公共).授权使用类型 等于 数量不足不可用)  40643

            QueryConfItemMatchAnswerDetailComRespDto queryConfItemMatchAnswerDetailComRespDto = null;
            QueryConfItemMatchAnswerDetailComReqDto queryConfItemMatchAnswerDetailComReqDto = new QueryConfItemMatchAnswerDetailComReqDto();
            queryConfItemMatchAnswerDetailComReqDto.setConfSchemeCode("COM_CONF_SCHEME");//CUSTOM_CONVENTION//sourceId:908914_1_40647
            queryConfItemMatchAnswerDetailComReqDto.setIsPlatData("TRUE");//sourceId:908920_1_40647
            if (reqDto != null) {
                queryConfItemMatchAnswerDetailComReqDto.setConfItemCode(reqDto.getNotEnoughCopiesAvailable());//SimpleFieldAssign//sourceId:908911_1_40647
            }

            /*D2-3查授权数量不足不可用文案[2486]   */
            Assert.isNull(queryConfItemMatchAnswerDetailComReqDto.getConfItemCode(), "D2-3判断云端部署授权可用分析(公共)-D2-3查授权数量不足不可用文案-配置项标识不能为空", false);
            Assert.isNull(queryConfItemMatchAnswerDetailComReqDto.getConfSchemeCode(), "D2-3判断云端部署授权可用分析(公共)-D2-3查授权数量不足不可用文案-配置方案标识不能为空", false);
            Assert.isNull(queryConfItemMatchAnswerDetailComReqDto.getIsPlatData(), "D2-3判断云端部署授权可用分析(公共)-D2-3查授权数量不足不可用文案-是否标准答案不能为空", false);
            queryConfItemMatchAnswerDetailComRespDto = confSchemeService.queryConfItemMatchAnswerDetailCom(queryConfItemMatchAnswerDetailComReqDto)/*vcase invoke isSameApp*/;


//ModelCode: receptionService
            ObtainReceiveFieldsRespDto receptionServiceRes_6 = null;
            if (queryConfItemMatchAnswerDetailComRespDto != null) {
                ObtainReceiveFieldsReqDto receptionServiceReq_3 = new ObtainReceiveFieldsReqDto();
                if (receptionServiceRes_2 != null) {
                    receptionServiceReq_3.setKeyOperateType(receptionServiceRes_2.getKeyOperateType());//SimpleFieldAssign//sourceId:909319_1_40654
                }
                if (queryConfItemMatchAnswerDetailComRespDto != null) {
                    receptionServiceReq_3.setServiceAbnormalWords(queryConfItemMatchAnswerDetailComRespDto.getEndValue());//SimpleFieldAssign//sourceId:909320_1_40654
                }

                /*M2-接收钥匙可用类型及授权异常文案[4007]  用于特殊方法接收上游入参。 */
                Assert.isNull(receptionServiceReq_3.getKeyOperateType(), "D2-3判断云端部署授权可用分析(公共)-M2-接收钥匙可用类型及授权异常文案-钥匙操作类型不能为空", false);
                receptionServiceRes_6 = nbSecurity.obtainReceiveFields(receptionServiceReq_3);


                receptionServiceRes_5 = receptionServiceRes_6;
            }
        } else if ((reqDto != null && reqDto.getAuthUseType() != null && reqDto.getAuthUseType().equals("EXPIRE__DISABLED"))) {
            //elseif(D2-3判断云端部署授权可用分析(公共).授权使用类型 等于 到期不可用)  40644

            QueryConfItemMatchAnswerDetailComRespDto queryConfItemMatchAnswerDetailComRespDto_2 = null;
            QueryConfItemMatchAnswerDetailComReqDto queryConfItemMatchAnswerDetailComReqDto_1 = new QueryConfItemMatchAnswerDetailComReqDto();
            queryConfItemMatchAnswerDetailComReqDto_1.setConfSchemeCode("COM_CONF_SCHEME");//CUSTOM_CONVENTION//sourceId:908902_1_40646
            queryConfItemMatchAnswerDetailComReqDto_1.setIsPlatData("TRUE");//sourceId:908908_1_40646
            if (reqDto != null) {
                queryConfItemMatchAnswerDetailComReqDto_1.setConfItemCode(reqDto.getExpiredUnavailableCopy());//SimpleFieldAssign//sourceId:908899_1_40646
            }

            /*D2-3查授权到期不可用文案[2486]   */
            Assert.isNull(queryConfItemMatchAnswerDetailComReqDto_1.getConfItemCode(), "D2-3判断云端部署授权可用分析(公共)-D2-3查授权到期不可用文案-配置项标识不能为空", false);
            Assert.isNull(queryConfItemMatchAnswerDetailComReqDto_1.getConfSchemeCode(), "D2-3判断云端部署授权可用分析(公共)-D2-3查授权到期不可用文案-配置方案标识不能为空", false);
            Assert.isNull(queryConfItemMatchAnswerDetailComReqDto_1.getIsPlatData(), "D2-3判断云端部署授权可用分析(公共)-D2-3查授权到期不可用文案-是否标准答案不能为空", false);
            queryConfItemMatchAnswerDetailComRespDto_2 = confSchemeService.queryConfItemMatchAnswerDetailCom(queryConfItemMatchAnswerDetailComReqDto_1)/*vcase invoke isSameApp*/;


//ModelCode: receptionService
            ObtainReceiveFieldsRespDto receptionServiceRes_7 = null;
            if (queryConfItemMatchAnswerDetailComRespDto_2 != null) {
                ObtainReceiveFieldsReqDto receptionServiceReq_4 = new ObtainReceiveFieldsReqDto();
                if (receptionServiceRes_2 != null) {
                    receptionServiceReq_4.setKeyOperateType(receptionServiceRes_2.getKeyOperateType());//SimpleFieldAssign//sourceId:909319_1_40655
                }
                if (queryConfItemMatchAnswerDetailComRespDto_2 != null) {
                    receptionServiceReq_4.setServiceAbnormalWords(queryConfItemMatchAnswerDetailComRespDto_2.getEndValue());//SimpleFieldAssign//sourceId:909320_1_40655
                }

                /*M2-接收钥匙可用类型及授权异常文案[4007]  用于特殊方法接收上游入参。 */
                Assert.isNull(receptionServiceReq_4.getKeyOperateType(), "D2-3判断云端部署授权可用分析(公共)-M2-接收钥匙可用类型及授权异常文案-钥匙操作类型不能为空", false);
                receptionServiceRes_7 = nbSecurity.obtainReceiveFields(receptionServiceReq_4);


                receptionServiceRes_5 = receptionServiceRes_7;
            }
        }
        JudgeCloudArrangeEmpowerAvailableComRespDto retData = new JudgeCloudArrangeEmpowerAvailableComRespDto();
        if (receptionServiceRes_5 != null) {
            retData.setKeyOperateType(receptionServiceRes_5.getKeyOperateType());//SimpleFieldAssign//sourceId:909699_1
            retData.setServiceAbnormalWords(receptionServiceRes_5.getServiceAbnormalWords());//SimpleFieldAssign//sourceId:909700_1
        }


        return retData;
    }

    /**
     * D2获取私有化或saas参数分析(公共)[6533]
     * gen by moon at 9/18/2023, 7:21:29 PM
     */
    @Trace(operationName = "D2获取私有化或saas参数分析(公共)")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public ObtainSecurityParamAvailableComRespDto obtainSecurityParamAvailableCom(ObtainSecurityParamAvailableComReqDto reqDto) {


        QueryObtainSecurityParamDataDetailRespDto obtainSecureParamRes_1 = null;
        ObtainReceiveFieldsRespDto receptionServiceRes_1 = null;
//virtualUsage M2获取物理化钥匙参数  40648
        //ModelCode: obtainSecureParam
        QueryObtainSecurityParamDataDetailRespDto obtainSecureParamRes = null;
        QueryObtainSecurityParamDataDetailReqDto obtainSecureParamReq = new QueryObtainSecurityParamDataDetailReqDto();
        if (reqDto != null) {
            obtainSecureParamReq.setAuthorizationKeyTypeCode(reqDto.getAuthorizationKeyTypeCode());//SimpleFieldAssign//sourceId:932175_1_40648
        }

        /*M2获取物理化钥匙参数[6537]  用于获取license内部安全参数数据 */
        Assert.isNull(obtainSecureParamReq.getAuthorizationKeyTypeCode(), "D2获取私有化或saas参数分析(公共)-M2获取物理化钥匙参数-开通钥匙类型标识不能为空", false);
        obtainSecureParamRes = nbSecurity.queryObtainSecurityParamDataDetail(obtainSecureParamReq);


        obtainSecureParamRes_1 = obtainSecureParamRes;
        if ((obtainSecureParamRes != null && obtainSecureParamRes.getDeployTypeCode() != null && obtainSecureParamRes.getDeployTypeCode().equals("LOCALITY"))) {
            //if(M2获取物理化钥匙参数.部署类型编码 等于 本地化部署)  40649

//ModelCode: receptionService
            ObtainReceiveFieldsRespDto receptionServiceRes = null;
            ObtainReceiveFieldsReqDto receptionServiceReq = new ObtainReceiveFieldsReqDto();
            if (obtainSecureParamRes != null) {
                receptionServiceReq.setSchOpenRecordId(obtainSecureParamRes.getSchOpenRecordId());//SimpleFieldAssign//sourceId:910417_1_40650
                receptionServiceReq.setSchOpenRecordCode(obtainSecureParamRes.getSchOpenRecordCode());//SimpleFieldAssign//sourceId:910418_1_40650
                receptionServiceReq.setAuthorizationObjectId(obtainSecureParamRes.getAuthorizationObjectId());//SimpleFieldAssign//sourceId:1123736_1_40650
                receptionServiceReq.setApplObjType(obtainSecureParamRes.getAuthorizationKeyTypeCode());//SimpleFieldAssign//sourceId:1089242_1_40650
                receptionServiceReq.setAuthType(obtainSecureParamRes.getSchemeAuthorizationType());//SimpleFieldAssign//sourceId:926556_1_40650
                receptionServiceReq.setAuthorizationNum(obtainSecureParamRes.getAuthorizationNum() != null ? Long.valueOf(obtainSecureParamRes.getAuthorizationNum()) : null);//SimpleFieldAssign//sourceId:910349_1_40650
                receptionServiceReq.setAuthorizationStartTime(obtainSecureParamRes.getAuthorizationStartTime());//SimpleFieldAssign//sourceId:910354_1_40650
                receptionServiceReq.setAuthorizationEndTime(obtainSecureParamRes.getAuthorizationEndTime());//SimpleFieldAssign//sourceId:910353_1_40650
            }

            /*M2-获取安全参数出参给下文是否可用分析[4007]  用于特殊方法接收上游入参。 */
            Assert.isNull(receptionServiceReq.getSchOpenRecordId(), "D2获取私有化或saas参数分析(公共)-M2-获取安全参数出参给下文是否可用分析-开通钥匙ID不能为空", false);
            receptionServiceRes = nbSecurity.obtainReceiveFields(receptionServiceReq);


            receptionServiceRes_1 = receptionServiceRes;
        } else if ((obtainSecureParamRes != null && obtainSecureParamRes.getDeployTypeCode() != null && obtainSecureParamRes.getDeployTypeCode().equals("SAAS"))) {
            //elseif(M2获取物理化钥匙参数.部署类型编码 等于 SAAS部署)  40651

            OmsSchemeOpenRecord omsSchemeOpenRecord = null;
            QuerySchemeOpenRecordDetailReq querySchemeOpenRecordDetailReq = new QuerySchemeOpenRecordDetailReq();
            querySchemeOpenRecordDetailReq.setSubjectLifeCycle("CURRENTLY_VALID");//sourceId:908539_1_40652
            if (reqDto != null) {
                querySchemeOpenRecordDetailReq.setAuthorizationKeyTypeCode(reqDto.getAuthorizationKeyTypeCode());//SimpleFieldAssign//sourceId:984762_1_40652
                querySchemeOpenRecordDetailReq.setTenantSpaceId(reqDto.getTenantSpaceId());//SimpleFieldAssign//sourceId:908538_1_40652
            }

            /*2-3-12查开通记录详情[1954]   */
            Assert.isNull(querySchemeOpenRecordDetailReq.getAuthorizationKeyTypeCode(), "D2获取私有化或saas参数分析(公共)-2-3-12查开通记录详情-开通钥匙类型标识不能为空", false);
            Assert.isNull(querySchemeOpenRecordDetailReq.getSubjectLifeCycle(), "D2获取私有化或saas参数分析(公共)-2-3-12查开通记录详情-主体生命周期不能为空", false);
            omsSchemeOpenRecord = mOmsSchemeOpenRecordService.querySchemeOpenRecordDetail(querySchemeOpenRecordDetailReq)/*vcase invoke 本地 method 方法调用;*/;


            OmsConfApplexRel omsConfApplexRel = null;
            if (omsSchemeOpenRecord != null) {
                QueryApplexConrelDetailReq queryApplexConrelDetailReq = new QueryApplexConrelDetailReq();
                queryApplexConrelDetailReq.setSubjectLifeCycle("CURRENTLY_VALID");//sourceId:1089179_1_47687
                if (omsSchemeOpenRecord != null) {
                    queryApplexConrelDetailReq.setSchOpenRecordId(omsSchemeOpenRecord.getSchOpenRecordId());//SimpleFieldAssign//sourceId:1089191_1_47687
                    queryApplexConrelDetailReq.setApplexType(omsSchemeOpenRecord.getApplObjType());//SimpleFieldAssign//sourceId:1089176_1_47687
                }
                if (reqDto != null) {
                    queryApplexConrelDetailReq.setAuthorizationKeyTypeCode(reqDto.getAuthorizationKeyTypeCode());//SimpleFieldAssign//sourceId:1089197_1_47687
                    queryApplexConrelDetailReq.setAscriptionSpaceId(reqDto.getTenantSpaceId());//SimpleFieldAssign//sourceId:1089178_1_47687
                }

                /*2-3-13查使用关系[2122]   */
                Assert.isNull(queryApplexConrelDetailReq.getSchOpenRecordId(), "D2获取私有化或saas参数分析(公共)-2-3-13查使用关系- 开通钥匙ID不能为空", false);
                Assert.isNull(queryApplexConrelDetailReq.getAuthorizationKeyTypeCode(), "D2获取私有化或saas参数分析(公共)-2-3-13查使用关系-开通钥匙类型标识不能为空", false);
                Assert.isNull(queryApplexConrelDetailReq.getApplexType(), "D2获取私有化或saas参数分析(公共)-2-3-13查使用关系-开通对象类型编码不能为空", false);
                Assert.isNull(queryApplexConrelDetailReq.getSubjectLifeCycle(), "D2获取私有化或saas参数分析(公共)-2-3-13查使用关系-主体生命周期不能为空", false);
                omsConfApplexRel = mOmsConfApplexRelService.queryApplexConrelDetail(queryApplexConrelDetailReq)/*vcase invoke 本地 method 方法调用;*/;


            }
//ModelCode: receptionService
            ObtainReceiveFieldsRespDto receptionServiceRes_2 = null;
            if (omsSchemeOpenRecord != null) {
                ObtainReceiveFieldsReqDto receptionServiceReq_1 = new ObtainReceiveFieldsReqDto();
                if (omsSchemeOpenRecord != null) {
                    receptionServiceReq_1.setSchOpenRecordId(omsSchemeOpenRecord.getSchOpenRecordId());//SimpleFieldAssign//sourceId:910417_1_40653
                    receptionServiceReq_1.setAuthUseType(omsSchemeOpenRecord.getAuthUseType());//SimpleFieldAssign//sourceId:910351_1_40653
                }
                if (obtainSecureParamRes != null) {
                    receptionServiceReq_1.setApplObjType(obtainSecureParamRes.getAuthorizationKeyTypeCode());//SimpleFieldAssign//sourceId:1089242_1_40653
                }

                /*M2-获取安全参数出参给下文是否可用分析[4007]  用于特殊方法接收上游入参。 */
                Assert.isNull(receptionServiceReq_1.getSchOpenRecordId(), "D2获取私有化或saas参数分析(公共)-M2-获取安全参数出参给下文是否可用分析-开通钥匙ID不能为空", false);
                receptionServiceRes_2 = nbSecurity.obtainReceiveFields(receptionServiceReq_1);


                receptionServiceRes_1 = receptionServiceRes_2;
            }
        }
        ObtainSecurityParamAvailableComRespDto retData = new ObtainSecurityParamAvailableComRespDto();
        if (receptionServiceRes_1 != null) {
            retData.setSchOpenRecordId(receptionServiceRes_1.getSchOpenRecordId());//SimpleFieldAssign//sourceId:910422_1
            retData.setSchOpenRecordCode(receptionServiceRes_1.getSchOpenRecordCode());//SimpleFieldAssign//sourceId:910423_1
            retData.setApplObjType(receptionServiceRes_1.getApplObjType());//SimpleFieldAssign//sourceId:1089198_1
            retData.setAuthorizationObjectId(receptionServiceRes_1.getAuthorizationObjectId());//SimpleFieldAssign//sourceId:1089199_1
            retData.setAuthType(receptionServiceRes_1.getAuthType());//SimpleFieldAssign//sourceId:910424_1
            retData.setAuthUseType(receptionServiceRes_1.getAuthUseType());//SimpleFieldAssign//sourceId:910425_1
            retData.setAuthorizationNum(receptionServiceRes_1.getAuthorizationNum());//SimpleFieldAssign//sourceId:910426_1
            retData.setAuthorizationStartTime(receptionServiceRes_1.getAuthorizationStartTime());//SimpleFieldAssign//sourceId:910427_1
            retData.setAuthorizationEndTime(receptionServiceRes_1.getAuthorizationEndTime());//SimpleFieldAssign//sourceId:910428_1
        }
        if (obtainSecureParamRes_1 != null) {
            retData.setDeployTypeCode(obtainSecureParamRes_1.getDeployTypeCode());//SimpleFieldAssign//sourceId:911947_1
        }


        return retData;
    }

    /**
     * D2-3判断部署授权可用分析(公共)[6534]
     * gen by moon at 5/9/2023, 4:30:41 PM
     */
    @Trace(operationName = "D2-3判断部署授权可用分析(公共)")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public JudgeArrangeEmpowerAvailableComRespDto judgeArrangeEmpowerAvailableCom(JudgeArrangeEmpowerAvailableComReqDto reqDto) {


        ObtainReceiveFieldsRespDto receptionServiceRes_5 = null;
//virtualUsage M2-约定钥匙类型“操作可用”  40657
        //ModelCode: receptionService
        ObtainReceiveFieldsRespDto receptionServiceRes = null;
        ObtainReceiveFieldsReqDto receptionServiceReq = new ObtainReceiveFieldsReqDto();
        receptionServiceReq.setKeyOperateType("OPERATE_USABLE");//sourceId:909127_1_40657

        /*M2-约定钥匙类型“操作可用”[4007]  用于特殊方法接收上游入参。 */
        Assert.isNull(receptionServiceReq.getKeyOperateType(), "D2-3判断部署授权可用分析(公共)-M2-约定钥匙类型“操作可用”-钥匙操作类型不能为空", false);
        receptionServiceRes = nbSecurity.obtainReceiveFields(receptionServiceReq);


//virtualUsage M2-约定钥匙类型“操作不可用”  40658
        //ModelCode: receptionService
        ObtainReceiveFieldsRespDto receptionServiceRes_2 = null;
        ObtainReceiveFieldsReqDto receptionServiceReq_1 = new ObtainReceiveFieldsReqDto();
        receptionServiceReq_1.setKeyOperateType("OPERATE_UNUSABLE");//sourceId:909515_1_40658

        /*M2-约定钥匙类型“操作不可用”[4007]  用于特殊方法接收上游入参。 */
        Assert.isNull(receptionServiceReq_1.getKeyOperateType(), "D2-3判断部署授权可用分析(公共)-M2-约定钥匙类型“操作不可用”-钥匙操作类型不能为空", false);
        receptionServiceRes_2 = nbSecurity.obtainReceiveFields(receptionServiceReq_1);


        if ((reqDto != null && reqDto.getAuthUseType() != null && reqDto.getAuthUseType().equals("USABLE"))) {
            //if(D2-3判断云端部署授权可用分析(公共).授权使用类型 等于 可用)  40642

//ModelCode: receptionService
            ObtainReceiveFieldsRespDto receptionServiceRes_4 = null;
            ObtainReceiveFieldsReqDto receptionServiceReq_2 = new ObtainReceiveFieldsReqDto();
            if (receptionServiceRes != null) {
                receptionServiceReq_2.setKeyOperateType(receptionServiceRes.getKeyOperateType());//SimpleFieldAssign//sourceId:909319_1_40656
            }

            /*M2-接收钥匙可用类型及授权异常文案[4007]  用于特殊方法接收上游入参。 */
            Assert.isNull(receptionServiceReq_2.getKeyOperateType(), "D2-3判断部署授权可用分析(公共)-M2-接收钥匙可用类型及授权异常文案-钥匙操作类型不能为空", false);
            receptionServiceRes_4 = nbSecurity.obtainReceiveFields(receptionServiceReq_2);


            receptionServiceRes_5 = receptionServiceRes_4;
        } else if ((reqDto != null && reqDto.getAuthUseType() != null && reqDto.getAuthUseType().equals("QUANTITY_INS_DISABLED"))) {
            //elseif(D2-3判断云端部署授权可用分析(公共).授权使用类型 等于 数量不足不可用)  40643

            QueryConfItemMatchAnswerDetailComRespDto queryConfItemMatchAnswerDetailComRespDto = null;
            QueryConfItemMatchAnswerDetailComReqDto queryConfItemMatchAnswerDetailComReqDto = new QueryConfItemMatchAnswerDetailComReqDto();
            queryConfItemMatchAnswerDetailComReqDto.setConfItemCode("IMPOWER_QUANTITY_LACK_UNUSABLE");//CUSTOM_CONVENTION//sourceId:908911_1_40647
            queryConfItemMatchAnswerDetailComReqDto.setConfSchemeCode("COM_CONF_SCHEME");//CUSTOM_CONVENTION//sourceId:908914_1_40647
            queryConfItemMatchAnswerDetailComReqDto.setIsPlatData("TRUE");//sourceId:908920_1_40647

            /*D2-3查授权数量不足不可用文案[2486]   */
            Assert.isNull(queryConfItemMatchAnswerDetailComReqDto.getConfItemCode(), "D2-3判断部署授权可用分析(公共)-D2-3查授权数量不足不可用文案-配置项标识不能为空", false);
            Assert.isNull(queryConfItemMatchAnswerDetailComReqDto.getConfSchemeCode(), "D2-3判断部署授权可用分析(公共)-D2-3查授权数量不足不可用文案-配置方案标识不能为空", false);
            Assert.isNull(queryConfItemMatchAnswerDetailComReqDto.getIsPlatData(), "D2-3判断部署授权可用分析(公共)-D2-3查授权数量不足不可用文案-是否标准答案不能为空", false);
            queryConfItemMatchAnswerDetailComRespDto = confSchemeService.queryConfItemMatchAnswerDetailCom(queryConfItemMatchAnswerDetailComReqDto)/*vcase invoke isSameApp*/;


//ModelCode: receptionService
            ObtainReceiveFieldsRespDto receptionServiceRes_6 = null;
            if (queryConfItemMatchAnswerDetailComRespDto != null) {
                ObtainReceiveFieldsReqDto receptionServiceReq_3 = new ObtainReceiveFieldsReqDto();
                if (receptionServiceRes_2 != null) {
                    receptionServiceReq_3.setKeyOperateType(receptionServiceRes_2.getKeyOperateType());//SimpleFieldAssign//sourceId:909319_1_40654
                }
                if (queryConfItemMatchAnswerDetailComRespDto != null) {
                    receptionServiceReq_3.setServiceAbnormalWords(queryConfItemMatchAnswerDetailComRespDto.getEndValue());//SimpleFieldAssign//sourceId:909320_1_40654
                }

                /*M2-接收钥匙可用类型及授权异常文案[4007]  用于特殊方法接收上游入参。 */
                Assert.isNull(receptionServiceReq_3.getKeyOperateType(), "D2-3判断部署授权可用分析(公共)-M2-接收钥匙可用类型及授权异常文案-钥匙操作类型不能为空", false);
                receptionServiceRes_6 = nbSecurity.obtainReceiveFields(receptionServiceReq_3);


                receptionServiceRes_5 = receptionServiceRes_6;
            }
        } else if ((reqDto != null && reqDto.getAuthUseType() != null && reqDto.getAuthUseType().equals("EXPIRE__DISABLED"))) {
            //elseif(D2-3判断云端部署授权可用分析(公共).授权使用类型 等于 到期不可用)  40644

            QueryConfItemMatchAnswerDetailComRespDto queryConfItemMatchAnswerDetailComRespDto_2 = null;
            QueryConfItemMatchAnswerDetailComReqDto queryConfItemMatchAnswerDetailComReqDto_1 = new QueryConfItemMatchAnswerDetailComReqDto();
            queryConfItemMatchAnswerDetailComReqDto_1.setConfItemCode("IMPOWER_EXPIRE_UNUSABLE");//CUSTOM_CONVENTION//sourceId:908899_1_40646
            queryConfItemMatchAnswerDetailComReqDto_1.setConfSchemeCode("COM_CONF_SCHEME");//CUSTOM_CONVENTION//sourceId:908902_1_40646
            queryConfItemMatchAnswerDetailComReqDto_1.setIsPlatData("TRUE");//sourceId:908908_1_40646

            /*D2-3查授权到期不可用文案[2486]   */
            Assert.isNull(queryConfItemMatchAnswerDetailComReqDto_1.getConfItemCode(), "D2-3判断部署授权可用分析(公共)-D2-3查授权到期不可用文案-配置项标识不能为空", false);
            Assert.isNull(queryConfItemMatchAnswerDetailComReqDto_1.getConfSchemeCode(), "D2-3判断部署授权可用分析(公共)-D2-3查授权到期不可用文案-配置方案标识不能为空", false);
            Assert.isNull(queryConfItemMatchAnswerDetailComReqDto_1.getIsPlatData(), "D2-3判断部署授权可用分析(公共)-D2-3查授权到期不可用文案-是否标准答案不能为空", false);
            queryConfItemMatchAnswerDetailComRespDto_2 = confSchemeService.queryConfItemMatchAnswerDetailCom(queryConfItemMatchAnswerDetailComReqDto_1)/*vcase invoke isSameApp*/;


//ModelCode: receptionService
            ObtainReceiveFieldsRespDto receptionServiceRes_7 = null;
            if (queryConfItemMatchAnswerDetailComRespDto_2 != null) {
                ObtainReceiveFieldsReqDto receptionServiceReq_4 = new ObtainReceiveFieldsReqDto();
                if (receptionServiceRes_2 != null) {
                    receptionServiceReq_4.setKeyOperateType(receptionServiceRes_2.getKeyOperateType());//SimpleFieldAssign//sourceId:909319_1_40655
                }
                if (queryConfItemMatchAnswerDetailComRespDto_2 != null) {
                    receptionServiceReq_4.setServiceAbnormalWords(queryConfItemMatchAnswerDetailComRespDto_2.getEndValue());//SimpleFieldAssign//sourceId:909320_1_40655
                }

                /*M2-接收钥匙可用类型及授权异常文案[4007]  用于特殊方法接收上游入参。 */
                Assert.isNull(receptionServiceReq_4.getKeyOperateType(), "D2-3判断部署授权可用分析(公共)-M2-接收钥匙可用类型及授权异常文案-钥匙操作类型不能为空", false);
                receptionServiceRes_7 = nbSecurity.obtainReceiveFields(receptionServiceReq_4);


                receptionServiceRes_5 = receptionServiceRes_7;
            }
        }
        JudgeArrangeEmpowerAvailableComRespDto retData = new JudgeArrangeEmpowerAvailableComRespDto();
        if (receptionServiceRes_5 != null) {
            retData.setKeyOperateType(receptionServiceRes_5.getKeyOperateType());//SimpleFieldAssign//sourceId:909699_1
            retData.setServiceAbnormalWords(receptionServiceRes_5.getServiceAbnormalWords());//SimpleFieldAssign//sourceId:909700_1
        }


        return retData;
    }

    /**
     * D2查询安全License详情[6685]
     * gen by moon at 5/14/2023, 6:09:27 PM
     */
    @Trace(operationName = "D2查询安全License详情")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public QuerySecurityLicenseDetailRespDto querySecurityLicenseDetail(QuerySecurityLicenseDetailReqDto reqDto) {


        QueryObtainSecurityParamDataDetailRespDto obtainSecureParamRes_1 = null;
//步骤0: M2查询获取安全参数数据详情 - queryObtainSecurityParamDataDetail
        //ModelCode: obtainSecureParam
        QueryObtainSecurityParamDataDetailRespDto obtainSecureParamRes = null;
        QueryObtainSecurityParamDataDetailReqDto obtainSecureParamReq = new QueryObtainSecurityParamDataDetailReqDto();
        if (reqDto != null) {
            obtainSecureParamReq.setAuthorizationKeyTypeCode(reqDto.getAuthorizationKeyTypeCode());//SimpleFieldAssign//sourceId:940830_1
        }

        /*M2查询获取安全参数数据详情[6537]  用于获取license内部安全参数数据 */
        Assert.isNull(obtainSecureParamReq.getAuthorizationKeyTypeCode(), "D2查询安全License详情-M2查询获取安全参数数据详情-开通钥匙类型标识不能为空", false);
        obtainSecureParamRes = nbSecurity.queryObtainSecurityParamDataDetail(obtainSecureParamReq);


        obtainSecureParamRes_1 = obtainSecureParamRes;

        QuerySecurityLicenseDetailRespDto retData = new QuerySecurityLicenseDetailRespDto();
        if (obtainSecureParamRes_1 != null) {
            retData.setSchOpenRecordId(obtainSecureParamRes_1.getSchOpenRecordId());//SimpleFieldAssign//sourceId:940839_1
            retData.setSchOpenRecordCode(obtainSecureParamRes_1.getSchOpenRecordCode());//SimpleFieldAssign//sourceId:940840_1
            retData.setDeployTypeCode(obtainSecureParamRes_1.getDeployTypeCode());//SimpleFieldAssign//sourceId:940841_1
            retData.setSchemeAuthorizationType(obtainSecureParamRes_1.getSchemeAuthorizationType());//SimpleFieldAssign//sourceId:940842_1
            retData.setAuthorizationNum(obtainSecureParamRes_1.getAuthorizationNum());//SimpleFieldAssign//sourceId:940843_1
            retData.setAuthorizationStartTime(obtainSecureParamRes_1.getAuthorizationStartTime());//SimpleFieldAssign//sourceId:940844_1
            retData.setAuthorizationEndTime(obtainSecureParamRes_1.getAuthorizationEndTime());//SimpleFieldAssign//sourceId:940845_1
        }


        return retData;
    }
    //
}
